package com.ben.chatroom.common.util;

import org.springframework.context.ApplicationContext;

/**
 * @author
 */
public class SpringContextUtil {

  private static ApplicationContext applicationContext;


  public static void setContext(ApplicationContext applicationContext) {
    SpringContextUtil.applicationContext = applicationContext;
  }

  public static <T> T getBean(Class<T> clazz) {
    if(null != applicationContext) {
      return applicationContext.getBean(clazz);
    }

    return null;
  }


}
